home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / ver_cont / cvs-1.8 / cvs-1 / cvs-1.8.1 / tools / pcl-cvs / pcl-cvs-lucid.el < prev    next >
Encoding:
Text File  |  1996-05-06  |  4.5 KB  |  135 lines

  1. ;;; Mouse and font support for PCL-CVS 1.3 running in Lucid GNU Emacs
  2. ;; @(#) Id: pcl-cvs-lucid.el,v 1.2 1993/05/31 19:37:34 ceder Exp 
  3. ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
  4.  
  5. ;; This file is part of GNU Emacs.
  6.  
  7. ;; GNU Emacs is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;; GNU General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  19. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22. ;; This simply adds a menu of the common CVS commands to the menubar and to
  23. ;; the right mouse button.  Clicking right moves point, and then pops up a
  24. ;; menu from which commands can be executed.
  25. ;; 
  26. ;; This could stand to be a lot more clever: for example, the "Commit Changes"
  27. ;; command should only be active on files for which there is something to
  28. ;; commit.  Also, some indication of which files the command applies to
  29. ;; (especially in the presence of multiple marked files) would be nice.
  30. ;;
  31. ;; Middle-click runs find-file.
  32.  
  33.  
  34. ;(require 'pcl-cvs)
  35. (load "pcl-cvs.el")
  36.  
  37. (defvar cvs-menu
  38.   '("CVS"
  39.     ["Find File"            cvs-mode-find-file        t]
  40.     ["Find File Other Window"        cvs-mode-find-file-other-window    t]
  41.     ["Interactively Merge (emerge)"    cvs-mode-emerge            t]
  42.     ["Diff against Repository"        cvs-mode-diff-cvs        t]
  43.     ["Diff against Backup Version"    cvs-mode-diff-backup        t]
  44.     "----"
  45.     ["Commit Changes to Repository"    cvs-mode-commit            t]
  46.     ["Revert File from Repository"    cvs-mode-undo-local-changes    t]
  47.     ["Add File to Repository"        cvs-mode-add            t]
  48.     ["Remove File from Repository"    cvs-mode-remove-file        t]
  49.     ["Ignore File"            cvs-mode-ignore            t]
  50.     ["Hide File"            cvs-mode-acknowledge        t]
  51.     ["Hide Handled Files"        cvs-mode-remove-handled        t]
  52.     "----"
  53.     ["Add ChangeLog Entry"    cvs-mode-add-change-log-entry-other-window t]
  54.     ["Show CVS Log"            cvs-mode-log            t]
  55.     ["Show CVS Status"            cvs-mode-status            t]
  56.     "----"
  57.     ["Mark File"            cvs-mode-mark            t]
  58.     ["Unmark File"            cvs-mode-unmark            t]
  59.     ["Mark All Files"            cvs-mode-mark-all-files        t]
  60.     ["Unmark All Files"            cvs-mode-unmark-all-files    t]
  61.     "----"
  62.     ["Quit"                bury-buffer            t]
  63.     ))
  64.  
  65. (defun cvs-menu (e)
  66.   (interactive "e")
  67.   (mouse-set-point e)
  68.   (beginning-of-line)
  69.   (or (looking-at "^[* ] ") (error "No CVS file line here"))
  70.   (popup-menu cvs-menu))
  71.  
  72. (defun cvs-mouse-find-file (e)
  73.   (interactive "e")
  74.   (mouse-set-point e)
  75.   (beginning-of-line)
  76.   (or (looking-at "^[* ] ") (error "No CVS file line here"))
  77.   (cvs-mode-find-file (point)))
  78.  
  79. (define-key cvs-mode-map 'button3 'cvs-menu)
  80. (define-key cvs-mode-map 'button2 'cvs-mouse-find-file)
  81.  
  82. (make-face 'cvs-header-face)
  83. (make-face 'cvs-filename-face)
  84. (make-face 'cvs-status-face)
  85.  
  86. (or (face-differs-from-default-p 'cvs-header-face)
  87.     (copy-face 'italic 'cvs-header-face))
  88.  
  89. (or (face-differs-from-default-p 'cvs-filename-face)
  90.     (copy-face 'bold 'cvs-filename-face))
  91.  
  92. (or (face-differs-from-default-p 'cvs-status-face)
  93.     (copy-face 'bold-italic 'cvs-status-face))
  94.  
  95.  
  96. (defun pcl-mode-motion-highlight-line (event)
  97.   (if (save-excursion
  98.     (let* ((window (event-window event))
  99.            (buffer (and window (window-buffer window)))
  100.            (point (and buffer (event-point event))))
  101.       (and point
  102.            (progn
  103.          (set-buffer buffer)
  104.          (goto-char point)
  105.          (beginning-of-line)
  106.          (looking-at "^[* ] ")))))
  107.       (mode-motion-highlight-line event)))
  108.  
  109. (defconst pcl-cvs-font-lock-keywords
  110.   '(("^In directory \\(.+\\)$" 1 cvs-header-face)
  111.     ("^[* ] \\w+ +\\(ci\\)" 1 cvs-status-face)
  112.     ("^[* ] \\(Conflict\\|Merged\\)" 1 cvs-status-face)
  113.     ("^[* ] \\w+ +\\(ci +\\)?\\(.+\\)$" 2 cvs-filename-face)
  114.     )
  115.   "Patterns to highlight in the *cvs* buffer.")
  116.  
  117. (defun pcl-cvs-fontify ()
  118.   ;;
  119.   ;; set up line highlighting
  120.   (require 'mode-motion)
  121.   (setq mode-motion-hook 'pcl-mode-motion-highlight-line)
  122.   ;;
  123.   ;; set up menubar
  124.   (if (and current-menubar (not (assoc "CVS" current-menubar)))
  125.       (progn
  126.     (set-buffer-menubar (copy-sequence current-menubar))
  127.     (add-menu nil "CVS" (cdr cvs-menu))))
  128.   ;;
  129.   ;; fontify mousable lines
  130.   (set (make-local-variable 'font-lock-keywords) pcl-cvs-font-lock-keywords)
  131.   (font-lock-mode 1)
  132.   )
  133.  
  134. (add-hook 'cvs-mode-hook 'pcl-cvs-fontify)
  135.